#! /bin/sh

name=pkg-config
from_source=pkg-config
revision=1
imagedeps="build-essential"

configure() {
        CFLAGS="$HOST_CFLAGS" \
        CXXFLAGS="$HOST_CXXFLAGS" \
        LDFLAGS="$HOST_LDFLAGS" \
    "${source_dir}"/configure \
        --prefix="${prefix}"
}

build() {
    make -j${parallelism}
}

package() {
    DESTDIR="${dest_dir}" make install
    mkdir -p "${dest_dir}${prefix}/share/pkgconfig/personality.d"
    cat <<EOF >"${dest_dir}${prefix}/share/pkgconfig/personality.d/${OS_TRIPLET}.personality"
Triplet: ${OS_TRIPLET}
SysrootDir: ${sysroot_dir}
DefaultSearchPaths: ${sysroot_dir}/usr/lib/pkgconfig:${sysroot_dir}/usr/share/pkgconfig
SystemIncludePaths: ${sysroot_dir}/usr/include
SystemLibraryPaths: ${sysroot_dir}/usr/lib
EOF
    ln -s pkgconf "${dest_dir}${prefix}/bin/${OS_TRIPLET}-pkg-config"

        strip_command=strip \
    post_package_strip
}
